import http from '@/utils/request'

// 积分兑换规则接口
interface PointsExchangeRule {
    id: number
    couponId: number
    points: number
    exchangeLimit: number
    status: number
    startTime: string
    endTime: string
    description: string
    createTime: string
    updateTime: string
    // 关联的优惠券信息
    coupon?: {
        id: number
        name: string
        type: number
        value: number
        minPoint: number
        startTime: string
        endTime: string
        status: number
    }
}

// 获取积分兑换规则列表
export const getExchangeRuleList = () => {
    return http.get('/coupon/api/exchange/list')
}

// 获取积分兑换规则详情
export const getExchangeRuleDetail = (id: number) => {
    return http.get(`/coupon/api/exchange/${id}`)
}

// 兑换优惠券
export const exchangeCoupon = (data: {
    userId: number
    couponId: number
}) => {
    return http.post('/coupon/api/user/exchange', data)
}

